#include "cmultimedia.h"
#include "cmd_parse/json_device_object.h"
#include <QJsonArray>
#include <QJsonObject>

Cmultimedia::Cmultimedia(QObject *parent) :
    CKnxControl(parent)
{
}

void Cmultimedia::setKnxObject(void *jsonArray)
{
    if(jsonArray!=NULL)
    {
        QJsonArray *objectArray = (QJsonArray *)jsonArray;

        if(objectArray->size()>0)
        {
            QJsonObject obj = objectArray->at(0).toObject();
            sc1.setKnxObjectBySend(obj.value("send").toString());
            sc1.cntDelegate = this->cntDelegate;
        }

        if(objectArray->size()>1)
        {
            QJsonObject obj = objectArray->at(1).toObject();
            sc2.setKnxObjectBySend(obj.value("send").toString());
            sc2.cntDelegate = this->cntDelegate;
        }

        if(objectArray->size()>2)
        {
            QJsonObject obj = objectArray->at(2).toObject();
            sc3.setKnxObjectBySend(obj.value("send").toString());
            sc3.cntDelegate = this->cntDelegate;
        }
    }
}


void Cmultimedia::readKnxAction()
{
    qDebug() << "Cmultimedia: should not read the status";
}

void Cmultimedia::execKnxAction(QString action,QString value)
{
    unsigned int index = action.toUInt();
    switch (index) {
    case 0:
        sc1.execKnxAction("on","");
        break;
    case 1:
        sc2.execKnxAction("on","");
        break;
    case 2:
        sc3.execKnxAction("on","");
        break;
    default:
        qDebug() << "Cmultimedia: action is error - " << index;
        break;
    }

}

QString Cmultimedia::actionFromStatus(QString address,QString value)
{
   return "null";
}

void Cmultimedia::execDeviceAction(QString action,QString value,QString unit)
{
    qDebug() << "class will do nothing is this function";
}
